

class Blog {


    async getRecent() {
        let sign =  await instance.dbHandle.connect();
        let sql = `select id, name, description, content, avatar, createTime from blog 
        order by createTime Desc limit 5;`;
        log.debug("获取最新博客的sql为 ",sql);
        try {
            let res = await instance.dbHandler.dbop(sql,sign);
            return res;
        } catch (error) {
            log.error("getHot数据库执行出错 error->",error);
        }
        
    }

    async getArticleById(id) {
        let sign =  await instance.dbHandle.connect();
        let sql = `select id, name, description, content, avatar, createTime from blog 
        where id = '${id}';`
        log.debug(`获取id为${id}的博客`);
        try {
            let res = await instance.dbHandler.dbop(sql,sign);
            return res[0];
        } catch (error) {
            log.error("getHot数据库执行出错 error->",error);
            return null;
        }
    }

}

exports.blog = new Blog();